﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting;
using LoggingSender;
using BaseModel;

namespace LoggingDataAcceptor
{
    public class RemoteSenderObservable //: IObservable<WellLoggingInfo[]>
    {
        private RemoteHandler obj;

        public RemoteSenderObservable()
        {
            TcpChannel chan = new TcpChannel();
            ChannelServices.RegisterChannel(chan);
            obj = (RemoteHandler)Activator.GetObject(typeof(RemoteHandler), "tcp://localhost:8085/SendData");
        }

        public void InitLoggingInfo(Equipment eqm, WellInfo wi)
        {
            obj.initLoggingInfo(eqm, wi);
        }

        public void StartSendLoggingData(WellLoggingInfo[] wli)
        { 
            if (obj == null)
                System.Console.WriteLine("Could   not   locate   server");
            else
            {
                obj.StartSendLoggingData(wli);
            }
        }

        public void notifySendLoggingData(WellLoggingPoint gp)
        {
            obj.SendData(gp);
        }

        public void endLoggingData()
        {
            obj.endLoggingData();
        }

        //public IDisposable Subscribe(IObserver<WellLoggingInfo[]> observer)
        //{           
        //    return null;
        //}
    }
}
